
package tilefoneia;
import java.util.ArrayList;
import java.io.*;

// I. Deligiannis
public abstract class Syndromitis {
    private String kodikos;
    private String AFM;
    private ArrayList <Syndesi> syndeseis;
    
    public Syndromitis(String kodikos, String AFM) {
        this.kodikos = kodikos;
        this. AFM = AFM;
        syndeseis = new ArrayList<Syndesi>();   
    }
    
    public abstract String getOnoma();   
    
    public void neaSyndesi(Syndesi syndesi) {
        System.out.println(syndesi);
        syndeseis.add(syndesi);
    }
      
    public void addKlisi(String arithmosTilefonou, String hmerominia, String ora_lepta, int diarkeia) {
        for (Syndesi syndesi: syndeseis) {
            if (syndesi.getArithmoTilefonou().equals(arithmosTilefonou)) {
                syndesi.addKlisi(hmerominia, ora_lepta, diarkeia);
            }
        }
    }
    // ΤΑΞΙΝΟΜΗΣΗ - ΕΚΤΥΠΩΣΗ - ΑΠΟΘΗΚΕΥΣΗ
    public void sortKinOmilias(PrintWriter pw) {
        for (Syndesi syndesi: syndeseis) 
            if (syndesi.getProgrOmilias() instanceof Omilias) {
                Omilias progOmilias = (Omilias)syndesi.getProgrOmilias();
                if (progOmilias.getArithmoKlisewn() > 0 ) {
                    System.out.println("\n\nΓια την " + syndesi);
                    progOmilias.ektyposiKlisewn(); // Εκτύπωση πριν την ταξινόμηση
                    progOmilias.taxinomisiKlisewn();
                    progOmilias.ektyposiKlisewn(); // Εκτύπωση μετά την ταξινόμηση
                    progOmilias.apothikeysiKlisewn(pw);
                }
            }
    }    
}
